/**
 * Created by lenovo on 2017/12/29.
 */
define(['ngApp', 'ngHttp', 'jquery', 'ngConstant', 'ngAlert'], function (ngApp, ngHttp, JQ, ngConstant, ngAlert) {
    ngApp.controller("login", function ($scope, $http, $timeout, $rootScope, $state, $uibModal, commonFn, $cookies,$window) {
        $('#login').height($(window).height());

        $scope.userMsg = {};
        $scope.loginBtn = function(){
            $http({
                url: ngConstant.interfaceHost + 'auth',
                method: 'POST',
                data:$scope.userMsg
                // headers: {'Authorization':$cookies.get("tokenQq")}
            }).then(function(res){
                if ( res.data.data == null ) {
                    ngAlert.errorMsg(res.data.errMsg);
                } else {
                    $cookies.put('token',res.data.data.token);
                    ngAlert.successMsg('登录成功');
                    $timeout(function(){
                        $state.go('leftTab1');
                    },2000);
                }

            },function(res){
                ngAlert.errorMsg(res.data.errMsg);
            });
        };


    })
});